package com.leslie.wukong.biz.product.handler;

import com.leslie.wukong.biz.product.domain.vo.ProductVO;
import com.leslie.wukong.common.core.constants.HttpStatus;
import com.leslie.wukong.common.core.constants.ValidationConstants;
import com.leslie.wukong.common.core.domain.RestResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;

/**
 * ClassName: PriceCheckHandler
 * Package: com.leslie.wukong.biz.product.handler
 * Description:
 * @date: 2024/12/3 18:42
 * @author: itcoder
 */
@Component
@Slf4j
public class PriceCheckHandler extends AbstractCheckHandler {
    @Override
    public RestResult handle(ProductVO param) {
        log.info("价格校验 Handler 开始....");
        boolean illegalPrice = param.getPrice().compareTo(BigDecimal.ZERO) <= 0;
        if (illegalPrice) {
            return RestResult.error(HttpStatus.VALIDATION, ValidationConstants.PARAM_PRICE_ILLEGAL_ERROR);
        }
        // 其他校验逻辑
        log.info("价格校验 Handler 通过....");
        return super.next(param);
    }
}
